cmake_minimum_required(VERSION 3.8)

set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_PATH}/scripts/buildsystems/vcpkg.cmake")

project(vulkan_tutorial)

set(CMAKE_CXX_STANDARD 14)

# Config vulkan
if (WIN32)
    set(Vulkan_INCLUDE_DIRS "$ENV{VULKAN_SDK}/Include")
    if (CMAKE_SIZEOF_VOID_P EQUAL 8)
        set(VULKAN_LIBRARY "$ENV{VULKAN_SDK}/Lib/vulkan-1.lib")
        set(VULKAN_STATIC_LIBRARY "$ENV{VULKAN_SDK}/Lib/vkstatic.1.lib")
    else()
        set(VULKAN_LIBRARY "$ENV{VULKAN_SDK}/Lib32/vulkan-1.lib")
        set(VULKAN_STATIC_LIBRARY "$ENV{VULKAN_SDK}/Lib32/vkstatic.1.lib")
    endif()
elseif (APPLE)
    set(CMAKE_FIND_FRAMEWORK NEVER)
    find_library(VULKAN_LIBRARY MoltenVK)
    set(CMAKE_FIND_FRAMEWORK ONLY)
    find_library(VULKAN_STATIC_LIBRARY MoltenVK)
    find_path(VULKAN_INCLUDE_DIR NAMES vulkan/vulkan.h HINTS
            "${VULKAN_LIBRARY}/Headers")
else()
    find_path(VULKAN_INCLUDE_DIR NAMES vulkan/vulkan.h HINTS
            "$ENV{VULKAN_SDK}/include")
    find_library(VULKAN_LIBRARY NAMES vulkan HINTS
            "$ENV{VULKAN_SDK}/lib")
endif()
include_directories(${Vulkan_INCLUDE_DIRS})
list(APPEND LIBS ${VULKAN_LIBRARY})
message(STATUS "Vulkan Include dirs: ${Vulkan_INCLUDE_DIRS} and libs: ${VULKAN_LIBRARY}")

# Config glfw3
find_package(glfw3 CONFIG REQUIRED)
list(APPEND LIBS glfw)

# Config glm
find_package(glm CONFIG REQUIRED)
list(APPEND LIBS glm)

# Demos
add_subdirectory(01.DevEnv)
add_subdirectory(02.AppFramework)
add_subdirectory(03.Instance)
add_subdirectory(04.ValidationLayers)
add_subdirectory(05.PhysicalDevice)
add_subdirectory(06.LogicalDevice)
add_subdirectory(07.WindowsSurface)
add_subdirectory(08.Swapchain)
add_subdirectory(09.ImageView)
add_subdirectory(10.GraphicPipeline)
add_subdirectory(11.ShaderModules)
add_subdirectory(12.FixedFunctions)